import qiniu
from flask import Blueprint, jsonify

bp = Blueprint('common', __name__, url_prefix='/common')


@bp.route('/')
def index():
    return 'common index'


@bp.route('/uptoken/')
def uptoken():
    # 七牛密钥
    access_key = 'a0CO3efhLnvU7ZyiqlhYILA4g2mYDGFj9IMYFWPD'
    secret_key = 'mKaamNuxF4zSr87FRg-uzB1KBEyzGXwW8Rbel4is'
    q = qiniu.Auth(access_key, secret_key)
    # 存储空间名称
    bucket = 'junemedia'
    token = q.upload_token(bucket)
    return jsonify({'uptoken': token})
